//
//  PCAddressManager.m
//  PromotionCode
//
//  Created by baken on 2018/2/11.
//  Copyright © 2018年 My. All rights reserved.
//

#import "PCAddressManager.h"
#import "PCAddressModel.h"

@implementation PCAddressManager

+ (void)getAddressWithUserID:(NSString *)uid andSessionID:(NSString *)sessionid andCompletionHandle:(void (^)(PCAddressModel *, NSError *))complete{
    [self EncryptPOST:[NSString stringWithFormat:@"%@%@",Api_URL,kGetAddress]
           parameters:[NSString stringWithFormat:@"userid=%@&sessionid=%@",uid,sessionid]
    completionHandler:^(id responseObj, NSError *error) {
        PCAddressModel *model = [PCAddressModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model,error);
    }];
}

+ (void)setAddressWithUserID:(NSString *)uid andSessionID:(NSString *)sessionid andName:(NSString *)name andAddress:(NSString *)address andPhone:(NSString *)phone andType:(NSString *)type andCompletionHandle:(void (^)(PCAddressModel *, NSError *))complete{
    [self EncryptPOST:[NSString stringWithFormat:@"%@%@",Api_URL,kSetAddress]
           parameters:[NSString stringWithFormat:@"userid=%@&sessionid=%@&name=%@&address=%@&phone=%@&type=%@",uid,sessionid,name,address,phone,type]
    completionHandler:^(id responseObj, NSError *error) {
        PCAddressModel *model = [PCAddressModel mj_objectWithKeyValues:responseObj];
        if (model.error_code != 0) {
            error = [self createError:model.error_msg];
        }
        complete(model,error);
    }];
}
@end
